//
//  UILabel+PP.m
//  pickpic
//
//  Created by GaoYongyue on 16/9/11.
//  Copyright © 2016年 MicroDream. All rights reserved.
//

#import "UILabel+PP.h"

@interface UILabel (PP_)
@property (readwrite, nonatomic, strong) UIControl *control;
@end

@implementation UILabel (PP)

- (UIControl *)control {
    UIControl *control = objc_getAssociatedObject(self, "control");

    if(control == nil) {
        control = [[UIControl alloc] init];
        [self addSubview:control];

        [control mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self);
        }];

        objc_setAssociatedObject(self, "control", control, OBJC_ASSOCIATION_RETAIN);
    }

    return control;
}

- (void)setActionBlock:(UIControlBlock)actionBlock forEvent:(UIControlEvents)event {

    self.userInteractionEnabled = YES;

    [self.control setActionBlock:actionBlock forControlEvents:event];
}

@end

